package com.hotelsystem.service.impl;

import com.hotelsystem.dao.CustomerMapper;
import com.hotelsystem.pojo.Customer;
import com.hotelsystem.service.CustomerService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class CustomerServiceImpl implements CustomerService {

    @Resource(name = "customerMapper")
    private CustomerMapper customerMapper;

    @Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
    @Override
    public List<Customer> list(String idNumber) throws Exception {
        return customerMapper.list(idNumber);
    }

    @Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
    @Override
    public Customer get(String idNumber) throws Exception {
        return customerMapper.get(idNumber);
    }

    @Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
    @Override
    public List<Customer> findCustomerList(Map<String, Object> map) throws Exception {
        return customerMapper.findCustomerList(map);
    }

    @Override
    public Integer deleteCustomer(Integer customerId) throws Exception {
        return customerMapper.deleteCustomer(customerId);
    }

    @Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
    @Override
    public Customer findCustomerById(Integer customerId) {
        return customerMapper.findCustomerById(customerId);
    }

    @Override
    public Integer updateCustomer(Customer customer) throws Exception {
        return customerMapper.updateCustomer(customer);
    }

}